<cfset Session.LoggedIn = FALSE> 


<!--- Use a query to find the user in the database --->
 <cfquery name="CheckUser" datasource="#Datasource#">
	SELECT *
	FROM tblpasswords
	WHERE IDN = #form.Display#
</cfquery>
<cfoutput> 


<cfif #CheckUser.recordcount# is 0> 
<cfset Reason = "the ID Number you\'ve typed is invalid. Try again.">
<SCRIPT>
				alert("Sorry!  Your login was unsuccessful because #Reason#"); self.location="login.cfm";
			</SCRIPT><cfabort><cfelse>

</cfif></cfoutput>






 
<!-- is the username present in the database? -->
<CFIF CheckUser.RecordCount GREATER THAN 0>
	 	<cfif TRIM(Display) IS #TRIM(CheckUser.idn)#>
			<!--- Ok, they pass, so we can set this session variable to TRUE and let them log in. --->
			<cfset Session.LoggedIn = TRUE>
			<!--- Ok, they pass, so we can set this session variable to TRUE and let them log in. --->
			
     
            <cfset Session.username = #checkuser.username#>
             <cfset Session.UserType = #checkuser.UserType#>
           
            <cfset Session.TechName = #checkuser.TechName#>
            <cfset Session.Admin = #checkuser.admin#>
			
	
		<CFELSE>
			<!--- Sorry, password is no good --->
			<cfset Reason = "the ID Number you\'ve typed is invalid. Try again.">
		</CFIF>
<CFELSE>
		<!--- This means that there were no query results and thusly, it must be the incorrect username --->
		<CFOUTPUT>
		<CFSET Reason = 'I could not find a ID, #Display# here. Please make certain that you have the correct ID Number or that you have been authorized to access this system.'>
		</CFOUTPUT>
</CFIF>

<cfif Session.LoggedIn eq 'True'>

			<!-- If the user has sucessfully logged in, we tranfer them to the homepage -->
			
			<cfset Session.username = #checkuser.username#>
     
             <cfset Session.TechName = #checkuser.TechName#>
             <cfset Session.Admin = #checkuser.admin#>
              <cfset Session.email = #checkuser.Email#>
              <cfset session.idn = #CheckUser.idn#>
				<!---<CFlocation url ="http://204.90.20.174/#APPLICATION.Directory#/postnews.cfm?username=#session.username#">--->
               <cfoutput> <CFlocation url ="https://#cgi.SERVER_NAME#/#APPLICATION.Directory#/index.cfm"></cfoutput>

	
<cfelse>

		<cfoutput>
        
			<SCRIPT>
				alert("Sorry!  Your login was unsuccessful because #Reason#"); self.location="login.cfm";
			</SCRIPT>	
		</cfoutput>

</cfif>
<!---<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Control Panel Login</title>
<style type="text/css">
<!--
.style7 {
	font-size: x-small;
	font-family: Verdana, Arial, Helvetica, sans-serif;
}
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: underline;
}
a:active {
	text-decoration: none;
}
.style10 {color: #FF0000}
-->
</style>
</head>

<body>
<table width="507" height="239" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
	<tr>
		<td height="135" valign="top"><img src="breakingnewsheader.gif" width="600" height="135" /></td>
	</tr>
	<tr>
		<td><center>
	    <span class="style7"><span class="style10">Login Incorrect</span><br />
	    <a href="file:///O|/Inetpub/wwwroot/controlpanel/login.cfm">Please Try Again</a> </span>
	                      </center></td>
    </tr>
</table>
</body>
</html>
--->